package edu.kjxy.day03.synchronizedOneThreadIn;

/**
 * 功能:
 * 作者:程序员欧阳子韩
 * 日期:2024/2/2 18:17
 */
public class ObjectService {
    public void serviceMethod(){
        try {
            //synchronized同步代码块
            synchronized (this){
                System.out.println("begin time=" + System.currentTimeMillis());
                Thread.sleep(2000);
                System.out.println("end time=" + System.currentTimeMillis());
            }
        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }
}
